package translated;

import java.util.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.jet.util.*;
import edu.pku.sei.modeler.model.common.MetaTypedList;

public class EnumGen
{
  protected static String nl;
  public static synchronized EnumGen create(String lineSeparator)
  {
    nl = lineSeparator;
    EnumGen result = new EnumGen();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "/**" + NL + " * Copyright (c) Software Institude of PKU" + NL + " * All rights reserved. " + NL + " * This program and the accompanying materials" + NL + " * are made available under the terms of the Eclipse Public License v1.0" + NL + " * which accompanies this distribution, and is available at" + NL + " * http://www.eclipse.org/legal/epl-v10.html" + NL + " *" + NL + " */" + NL + "package ";
  protected final String TEXT_2 = ";" + NL + "// imports:" + NL + "import org.w3c.dom.Element;" + NL + "" + NL + "import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;" + NL + "import edu.pku.sei.modeler.model.common.*;" + NL + "import edu.pku.sei.modeler.model.core.*;" + NL + "import edu.pku.sei.modeler.model.xml.XMLUtility;" + NL + "import ";
  protected final String TEXT_3 = ";" + NL + "" + NL + "" + NL + "/**" + NL + " * @generated" + NL + " *" + NL + " */" + NL + "public class ";
  protected final String TEXT_4 = " extends MetaModelElement{" + NL + "\t// attributes" + NL + "\t";
  protected final String TEXT_5 = NL + "\tpublic static final ";
  protected final String TEXT_6 = " ";
  protected final String TEXT_7 = " = new ";
  protected final String TEXT_8 = "(0);" + NL + "\t";
  protected final String TEXT_9 = NL + "\tpublic static final ";
  protected final String TEXT_10 = " ";
  protected final String TEXT_11 = " = new ";
  protected final String TEXT_12 = "(";
  protected final String TEXT_13 = ");" + NL + "\t";
  protected final String TEXT_14 = NL + "\tpublic static final ";
  protected final String TEXT_15 = " ";
  protected final String TEXT_16 = " = new ";
  protected final String TEXT_17 = "(0);" + NL + "\t";
  protected final String TEXT_18 = NL + "\tpublic static final ";
  protected final String TEXT_19 = " ";
  protected final String TEXT_20 = " = new ";
  protected final String TEXT_21 = "(";
  protected final String TEXT_22 = ");" + NL + "\t";
  protected final String TEXT_23 = NL + "\tpublic static final ";
  protected final String TEXT_24 = " ";
  protected final String TEXT_25 = " = new ";
  protected final String TEXT_26 = "(0);" + NL + "\t";
  protected final String TEXT_27 = NL + "\tpublic static final ";
  protected final String TEXT_28 = " ";
  protected final String TEXT_29 = " = new ";
  protected final String TEXT_30 = "(";
  protected final String TEXT_31 = ");" + NL + "\t";
  protected final String TEXT_32 = NL + "\tint enumValue;" + NL + "\tpublic ";
  protected final String TEXT_33 = "() {" + NL + "\t\tthis.enumValue = 0;" + NL + "\t}" + NL + "\tpublic ";
  protected final String TEXT_34 = "(int enumValue) {" + NL + "\t\tthis.enumValue = enumValue;" + NL + "\t}" + NL + "\tpublic int getValue() {" + NL + "\t\treturn enumValue;" + NL + "\t}" + NL + "\tpublic boolean equals(";
  protected final String TEXT_35 = " obj) {" + NL + "\t\tif(obj.getValue() == enumValue)return true;" + NL + "\t\treturn false;" + NL + "\t}" + NL + "}" + NL + " " + NL + " " + NL + " " + NL + " ";
  protected final String TEXT_36 = NL + " ";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     MetaEnum enu = (MetaEnum) argument;
   MetaTypedList mel = enu.getEnumLiterals(); 

    stringBuffer.append(TEXT_1);
    stringBuffer.append(PackageRetriever.retrievePackage(enu));
    stringBuffer.append(TEXT_2);
    stringBuffer.append(ModelerConstants.pkgBase + "." + ModelerConstants.modelBase + "." + "ModelPackage");
    stringBuffer.append(TEXT_3);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_4);
    
	if(mel.size() == 0) {
	}
	else if(mel.size() == 1) {
		MetaEnumLiteral lit = (MetaEnumLiteral)mel.get(0);
		if(lit.getValue()<=0) {
	
    stringBuffer.append(TEXT_5);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(lit.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_8);
    
		}
		else {
	
    stringBuffer.append(TEXT_9);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_10);
    stringBuffer.append(lit.getName());
    stringBuffer.append(TEXT_11);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_12);
    stringBuffer.append(lit.getValue());
    stringBuffer.append(TEXT_13);
    
		}
	}
	else {
		for(int i=0; i<mel.size()-1; i++) {
			MetaEnumLiteral lit = (MetaEnumLiteral)mel.get(i);
			if(lit.getValue()<=0) {
	
    stringBuffer.append(TEXT_14);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_15);
    stringBuffer.append(lit.getName());
    stringBuffer.append(TEXT_16);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_17);
    
			}
			else {
	
    stringBuffer.append(TEXT_18);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_19);
    stringBuffer.append(lit.getName());
    stringBuffer.append(TEXT_20);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_21);
    stringBuffer.append(lit.getValue());
    stringBuffer.append(TEXT_22);
    
			}
		}
		MetaEnumLiteral lit = (MetaEnumLiteral)mel.get(mel.size()-1);
		if(lit.getValue()<=0) {
	
    stringBuffer.append(TEXT_23);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_24);
    stringBuffer.append(lit.getName());
    stringBuffer.append(TEXT_25);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_26);
    
		}
		else {
	
    stringBuffer.append(TEXT_27);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_28);
    stringBuffer.append(lit.getName());
    stringBuffer.append(TEXT_29);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_30);
    stringBuffer.append(lit.getValue());
    stringBuffer.append(TEXT_31);
    
		}
	}
	
    stringBuffer.append(TEXT_32);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_33);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_34);
    stringBuffer.append(enu.getName());
    stringBuffer.append(TEXT_35);
    stringBuffer.append(TEXT_36);
    return stringBuffer.toString();
  }
}
